build(mac): split bundle step and capture stderr for diagnostics#9965
Conversation
The macOS x64 appbundle build can fail inside `yarn run bundle` while producing zero console output -- the Jenkins log goes straight from "yarn install ... Done with warnings" to the EXIT trap's failure message, leaving no signal as to whether linter, webpack, or a native module load was the culprit (build #1293 on pgabf-macos-x64 is the prompting example). Split the bundled script into its constituent steps and merge stderr into stdout so any error text reaches the console even if Jenkins' shell step drops a tail buffer: yarn install yarn run git:hash # cheap source-hash capture, moved up front yarn run linter yarn run webpacker `git:hash` is a pure `git log` redirect (see web/package.json) with no node-module dependency, but `yarn run` needs node_modules so it stays after install. Pulling it before the heavy steps means the commit_hash file lands on disk even if webpack later bails out. Env vars NODE_ENV=production and NODE_OPTIONS=--max-old-space-size=3072 are set explicitly to mirror the cross-env wrapper inside the top-level "bundle" npm script, so build output stays byte-identical to before. No-op for successful builds; pure diagnostics win on failure.
WalkthroughBuild script refactored to separate the frontend build sequence into discrete steps: yarn install, git hash recording, linting, and webpack bundling with explicit environment configuration. NODE_ENV and NODE_OPTIONS are set during linting/bundling then unset afterward, improving console output visibility during these operations. ChangesFrontend Build Sequence Refactoring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/mac/build-functions.sh`:
- Around line 294-302: Add explicit failure handling to the two commands that
currently lack it: ensure the "yarn install 2>&1" invocation and the "yarn run
git:hash" invocation both propagate errors (e.g., append "|| exit 1") so the
script fails fast on install or git:hash errors; update the calls where found in
build-functions.sh to match the existing error-handling pattern used elsewhere
(see the earlier commands that use "|| exit 1") so subsequent build steps don't
run on a broken state.
- Around line 313-315: The yarn commands for linting and webpacking currently
run without checking failure: ensure the build stops on errors by adding
explicit error handling for the two invocations (the lines running "yarn run
linter" and "yarn run webpacker"): either enable a fail-fast shell option (e.g.,
set -e at the top of the script) or append a check to each command so that if
"yarn run linter" or "yarn run webpacker" exits non‑zero you print a clear error
and exit 1 (e.g., use "yarn run linter" ... || { echo 'Lint failed'; exit 1; }
and similarly for "yarn run webpacker") so the build cannot continue with failed
lint or bundle steps.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dd41138a-4693-402f-8506-08579a0aafa2
📒 Files selected for processing (1)
pkg/mac/build-functions.sh
Summary
yarn run bundlewith zero console output — the Jenkins log jumps fromyarn install ... Done with warningsstraight to the EXIT trap's failure message, leaving no signal as to whether linter, webpack, or a native module load was the culprit. Prompted by build #1293 onpgabf-macos-x64(arm64 of the same commit passed cleanly).yarn run bundlecall inpkg/mac/build-functions.sh::_complete_bundlewith its individual steps, with stderr merged to stdout and a stage marker echoed before each, so the next failure is diagnosable:NODE_ENV=productionandNODE_OPTIONS=--max-old-space-size=3072are exported explicitly to mirror thecross-envwrapper inside the top-levelbundlenpm script, so build output stays byte-identical to before.No-op for successful builds; pure diagnostics win on failure.
Test plan
pgadmin4-macos-qaon bothmacos-x64andmacos-arm64and confirm the appbundle still builds successfully.==> Running ...markers appear in order, followed by the usual<s> [webpack.Progress] …lines..jsx) and confirm the error text now reaches the console between the==> Running webpack bundle...marker and the EXIT trap message.Summary by CodeRabbit